<template>
    <div>
        <Card>
            <Form ref="formData" :model="formDate" :label-width="100">
                <Row>
                    <Col :xs="24" :sm="12" :md="12" :lg="8" :xl="6" :xxl="6">
                        <FormItem label="宽限天数">
                            <InputNumber :min="0" v-model="formDate.gracePeriod" style="width: 200px"/>
                        </FormItem>
                    </Col>
                    <Col :xs="24" :sm="12" :md="12" :lg="8" :xl="6" :xxl="6">
                        <FormItem>
                            <Button type="primary" @click="save">保存</Button>
                        </FormItem>
                    </Col>
                </Row>
            </Form>
        </Card>
    </div>
</template>
<script>
    import {
        findCompanyGrace,
        saveCompanyGrace
    } from "_p/basic/api/contract/business/system-business";

    export default {
        data() {
            return {
                formDate: {
                    gracePeriod: null,
                },
            }
        },
        mounted() {
            //载入中查询
            this.init();
        },
        methods: {
            init() {
                //查询公司宽限期
                this.getCompanyInfo();
            },
            getCompanyInfo() {
                findCompanyGrace().then(res => {
                    this.loading = false;
                    if (res.code === "0000"&&res.data) {
                        this.formDate = res.data;
                    } else {
                        // this.$Message.error("Fail!");
                    }
                });
            },
            save() {
                saveCompanyGrace(this.formDate).then(res => {
                    this.loading = false;
                    if (res.code === "0000") {
                        this.formDate = res.data;
                        this.$Message.success("保存成功!");
                    }
                });
            }
        }
    }
</script>
